<?php
/*
 * This page is for growth for 1-5 years.
 */
include '../../include/config.php';
$q = mysql_query("select * from baby_15_growth where bid = '" . $_COOKIE['bid'] . "'");
$rp = $_SERVER['REQUEST_URI'];
if (mysql_num_rows($q) == 0) {
    echo 'not inserted any data...:P';
    ?>
    <form method="post" action="../child/child_15.php" >
        <input type="hidden" name="action" value="insert_15" />
        <input type="hidden" name="rp" value="<?php echo $rp; ?>" />
        <input type="submit" value="Start Entry" />
    </form>
<?php } else {
    ?>

    <script>
            
        function wl(val, type){
            var type= document.getElementById(type).value;
            if(type=='kg')
            {
                var value = document.getElementById(val).value /2.2046;
                document.getElementById(val).value = value;
            }
            if(type=='lbs'){
                var value = document.getElementById(val).value * 2.2046;
                document.getElementById(val).value = value;
            }
        }
            
        //    function w2l(we,lb){
        //        var w = we;
        //        var l = lb;
        //        var weight = document.getElementById(w).value;
        //        var newight = weight * 2.2046;
        //        alert('Weight = '+weight+'\n Lbs = '+newight);
        //        document.getElementById(l).value = newight;
        //    }
        //    function l2w(we,lb){
        //        var w = we;
        //        var l = lb;
        //        var lbs = document.getElementById(l).value;
        //        var newlbs = lbs / 2.2046;
        //        alert('Lbs = '+lbs+'\nWeight = '+newlbs);
        //        document.getElementById(w).value = newlbs;
        //    }
        function fc(val,type){
            var type= document.getElementById(type).value;
            if(type=='cm'){
                var value = document.getElementById(val).value / 0.03;           
                document.getElementById(val).value= value;
                //  alert('cm selected. \nCM ='+value);
            }
            if(type=='ft')
            {
                var value = document.getElementById(val).value * 0.03;           
                document.getElementById(val).value= value;
                //    alert('evaluating foot');
            }        
        }  


    </script>
    <?php while ($row = mysql_fetch_array($q)) { ?>
        <form method="post" action="../child/child_15.php" >
            <table style="width: 600px; border-collapse: collapse; " border="1" >
                <tr>
                    <th style="width: 100px; " >AGE</th>
                    <th style="width: 125px;">WEIGHT</th>
                    <th style="width: 125px;">LENGTH</th>       
                    <th style="width: 150px;">KIND OF FEEDING</th>
                </tr>
                <tr style="height: 100px;">
                    <th>1 YEAR</th>
                    <td>
                <center>
                    <input type="text" size="5" name="1" id="1m0v" value="<?= $row[1] ?>" />
                    <select name="2" style="width: 2;" id="1m0t" onchange="wl('1m0v','1m0t')" >
                        <option value="kg" <?php if ($row[2] == 'kg') { ?> selected="selected"  <?php } ?>>Kg</option>
                        <option value="lbs" <?php if ($row[2] == 'lbs') { ?> selected="selected"  <?php } ?>>Lbs</option>
                    </select>
                </center>
                </td>
                <td>
                <center>
                    <input type="text" size="5" name="3" id="1m1v" value="<?= $row[3] ?>" />
                    <select name="4" id="1m1t" onchange="fc('1m1v','1m1t')" >
                        <option value="cm" <?php if ($row[4] == 'cm') { ?> selected="selected"  <?php } ?>>cm</option>
                        <option value="ft" <?php if ($row[4] == 'lbs') { ?> selected="selected"  <?php } ?>>ft</option>
                    </select>
                </center>
                </td>
                <td>
                    <textarea name="5" cols="20" rows="5" ><?= $row[5] ?></textarea>
                </td>
                </tr>
                <tr style="height: 100px;">
                    <th>2 YEAR</th>
                    <td>
                <center>
                    <input type="text" size="5" name="6" id="2m0v" value="<?= $row[6] ?>" />
                    <select name="7" style="width: 2;" id="2m0t" onchange="wl('2m0v','2m0t')" >
                        <option value="kg" <?php if ($row[7] == 'kg') { ?> selected="selected"  <?php } ?>>Kg</option>
                        <option value="lbs" <?php if ($row[7] == 'lbs') { ?> selected="selected"  <?php } ?>>Lbs</option>
                    </select>
                </center>
                </td>
                <td>
                <center>
                    <input type="text" size="5" name="8" id="2m1v" value="<?= $row[8] ?>" />
                    <select name="9" id="2m1t" onchange="fc('2m1v','2m1t')" >
                        <option value="cm" <?php if ($row[9] == 'cm') { ?> selected="selected"  <?php } ?>>cm</option>
                        <option value="ft" <?php if ($row[9] == 'ft') { ?> selected="selected"  <?php } ?>>ft</option>
                    </select>
                </center>
                </td>
                <td>
                    <textarea name="10" cols="20" rows="5" ><?= $row[10] ?></textarea>
                </td>
                </tr>
                <tr style="height: 100px;">
                    <th>3 YEAR</th>
                    <td>
                <center>
                    <input type="text" size="5" name="11" id="3m0v" value="<?= $row[11] ?>" />
                    <select name="12" style="width: 2;" id="3m0t" onchange="wl('3m0v','3m0t')" >
                        <option value="kg" <?php if ($row[12] == 'kg') { ?> selected="selected"  <?php } ?>>Kg</option>
                        <option value="lbs" <?php if ($row[12] == 'lbs') { ?> selected="selected"  <?php } ?>>Lbs</option>
                    </select>
                </center>
                </td>
                <td>
                <center>
                    <input type="text" size="5" name="13" id="3m1v" value="<?= $row[13] ?>" />
                    <select name="14" id="3m1t" onchange="fc('3m1v','3m1t')" >
                        <option value="cm" <?php if ($row[14] == 'cm') { ?> selected="selected"  <?php } ?>>cm</option>
                        <option value="ft" <?php if ($row[14] == 'ft') { ?> selected="selected"  <?php } ?>>ft</option>
                    </select>
                </center>
                </td>
                <td>
                    <textarea name="15" cols="20" rows="5" ><?= $row[15] ?></textarea>
                </td>
                </tr>
                <tr style="height: 100px;">
                    <th>4 YEAR</th>
                    <td>
                <center>
                    <input type="text" size="5" name="16" id="4m0v" value="<?= $row[16] ?>"/>
                    <select name="17" style="width: 2;" id="4m0t" onchange="wl('4m0v','4m0t')" >
                        <option value="kg" <?php if ($row[17] == 'kg') { ?> selected="selected"  <?php } ?>>Kg</option>
                        <option value="lbs" <?php if ($row[17] == 'lbs') { ?> selected="selected"  <?php } ?>>Lbs</option>
                    </select>
                </center>
                </td>
                <td>
                <center>
                    <input type="text" size="5" name="18" id="4m1v" value="<?= $row[18] ?>"/>
                    <select name="19" id="4m1t" onchange="fc('4m1v','4m1t')" >
                        <option value="cm" <?php if ($row[19] == 'cm') { ?> selected="selected"  <?php } ?> >cm</option>
                        <option value="ft" <?php if ($row[19] == 'ft') { ?> selected="selected"  <?php } ?> >ft</option>
                    </select>
                </center>
                </td>
                <td>
                    <textarea name="20" cols="20" rows="5" ><?= $row[20] ?></textarea>
                </td>
                </tr>
                <tr style="height: 100px;">
                    <th>5 YEAR</th>
                    <td>
                <center>
                    <input type="text" size="5" name="21" id="5m0v" value="<?= $row[21] ?>"/>
                    <select name="22" style="width: 2;" id="5m0t" onchange="wl('5m0v','5m0t')" >
                        <option value="kg" <?php if ($row[22] == 'kg') { ?> selected="selected"  <?php } ?>>Kg</option>
                        <option value="lbs" <?php if ($row[22] == 'lbs') { ?> selected="selected"  <?php } ?>>Lbs</option>
                    </select>
                </center>
                </td>
                <td>
                <center>
                    <input type="text" size="5" name="23" id="5m1v" value="<?= $row[23] ?>"/>
                    <select name="24" id="5m1t" onchange="fc('5m1v','5m1t')" >
                        <option value="cm" <?php if ($row[24] == 'cm') { ?> selected="selected"  <?php } ?>>cm</option>
                        <option value="ft" <?php if ($row[24] == 'ft') { ?> selected="selected"  <?php } ?>>ft</option>
                    </select>
                </center>
                </td>
                <td>
                    <textarea name="25" cols="20" rows="5" ><?= $row[25] ?></textarea>
                </td>
                </tr>

            </table>
            <input type="hidden" name="sr" value="<?php echo $row['sr']; ?>" />
            <input type="hidden" name="action"  value="update15" />
            <input type="hidden" name="rp" value="<?php echo $rp; ?>" />
            <input type="submit" style="width: 200px; height: 40px; color: green; float: left; " value="UPDATE" />
        </form>
    <?php }
} ?>